﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GG.Base
{
    public static class PositionUtils
    {
        public static int Wrap(int value, int max)
        {
            int newVal = value % max;
            return (newVal > 0) ? newVal : newVal + max;
        }

        public static int Crop(int value, int min, int max)
        {
            return (value > min) ? ((value < max) ? value : max) : min;
        }

        public static double Crop(double value, double min, double max)
        {
            return (value > min) ? ((value < max) ? value : max) : min;
        }
    }
}
